package com.topboya.linker.ui.adapter;

import android.widget.CheckBox;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.topboya.linker.R;
import com.topboya.linker.model.levelitem.DepartmentGroupBo;
import com.topboya.linker.model.levelitem.FollowUserGroup;

import java.util.List;


public class FollowUserAdapter extends BaseQuickAdapter<FollowUserGroup, BaseViewHolder> {

    private static final String TAG = "FollowUserAdapter:";
    public FollowUserAdapter(List<FollowUserGroup> followUserGroups) {

        super(R.layout.select_team_item, followUserGroups);
}

    @Override
    protected void convert(BaseViewHolder viewHolder,FollowUserGroup followUserGroup) {

         String  departname = followUserGroup.getName();
         viewHolder.setText(R.id.tv_head_name,departname);
         viewHolder.setText(R.id.tv_head_num,"("+followUserGroup.getSelectNum()+"/"+followUserGroup.getTotalNum()+")");

        ((CheckBox)viewHolder.getView(R.id.ck_select)).setChecked(followUserGroup.isCheked());
         viewHolder.addOnClickListener(R.id.ck_select);


        if (followUserGroup.isSub()){

            viewHolder.setGone(R.id.tv_head_pic,false);
            viewHolder.setGone(R.id.ck_select,false);
            viewHolder.setGone(R.id.tv_head_num,true);

        }else {

           if (null !=departname){
               String  departnamepic = departname.substring(departname.length()-2);
               viewHolder.setGone(R.id.tv_head_pic,true);
               viewHolder.setGone(R.id.ck_select,true);
               viewHolder.setGone(R.id.tv_head_num,false);
               viewHolder.setText(R.id.tv_head_pic,departnamepic);
           }



        }

    }

}
